<template>
	<div class="data_detail_wrapper">
		<div class="item">
			<div class="label">实验名称：</div>
			<div class="content">{{ data.name }}</div>
		</div>
		<div class="item">
			<div class="label">所属课题：</div>
			<topic-info :data="topicData"></topic-info>
		</div>
		<el-row>
			<el-col :span="8">
				<div class="item">
					<div class="label">申请人：</div>
					<div class="content">{{ data.createName }}</div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="item">
					<div class="label">测量技术：</div>
					<div class="content">{{ data.filed1 }}</div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="item">
					<div class="label">强磁场PI：</div>
					<div class="content">
						{{ formatCoagentName(data) }}
					</div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="item">
					<div class="label">实验机时：</div>
					<div class="content">{{ data.machineHour }}</div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="item" v-if="data.isSave === '1'">
					<div class="label">当前状态：</div>
					<div class="content">{{ statusFormat(data) }}</div>
				</div>
			</el-col>
		</el-row>
	</div>
</template>

<script>
import { mapGetters } from 'vuex';
import topicInfo from '../topicInfo';
export default {
	components: { topicInfo },
	props: {
		data: { type: Object, default: () => {} }
	},
	data() {
		return {
			tableData: []
		};
	},
	computed: {
		...mapGetters(['dictEnums', 'principalData']),
		topicData() {
			return this.data.topic || {};
		},

		applyFileData() {
			return !this.data.fileJson ? [] : JSON.parse(this.data.fileJson);
		}
	},
	watch: {},
	methods: {
		formatModeType(data) {
			let info = this.dictEnums['EXPERIMENT_WAY'].find((n) => n.value === data.modeType);
			return !info ? '' : info.msg;
		},

		formatCoagentName(data) {
			let info = this.principalData.find((item) => item.id === data.filed2);
			return !info ? '' : info.userName;
		},

		//获取当前状态
		statusFormat(data) {
			if (data.audit === '3') {
				return '待审核';
			} else if (data.audit === '2') {
				return '不通过';
			} else {
				return '已完成';
			}
		},

		//下载文件
		handleDownloadFile(data) {
			let suffix = data.url.split('.');
			let name = `${data.name}.${data.suffix || suffix[suffix.length - 1]}`;
			this.$fileDownload(data.url, name);
		}
	}
};
</script>

<style lang="scss" scoped></style>
